from django_filters import rest_framework

from apps.tests.models import Case, Step, CaseRunLog, Tag


class CaseFilter(rest_framework.FilterSet):
    name = rest_framework.CharFilter(lookup_expr='contains')
    module = rest_framework.BaseInFilter(lookup_expr='in')
    tag = rest_framework.BaseInFilter(lookup_expr='in')

    class Meta:
        model = Case
        fields = ['name', 'module', 'type', 'tag', 'project']


class TagFilter(rest_framework.FilterSet):
    name = rest_framework.CharFilter(lookup_expr='contains')

    class Meta:
        model = Tag
        fields = '__all__'


class StepFilter(rest_framework.FilterSet):
    name = rest_framework.CharFilter(lookup_expr='contains')
    module = rest_framework.BaseInFilter(lookup_expr='in')

    class Meta:
        model = Step
        fields = ['name', 'module', 'project']


class CaseRunLogsFilter(rest_framework.FilterSet):

    class Meta:
        model = CaseRunLog
        fields = ['id', 'case', 'report']
